package sebastiankerckhof.render.raytrace.Hit;

import sebastiankerckhof.math.Vector3f;
import sebastiankerckhof.scene.geometry.Surface;
import sebastiankerckhof.scene.geometry.Triangle;
import sebastiankerckhof.scene.texture.TexCoord2f;

public class Hit {
	public static final float INFINITY = Float.POSITIVE_INFINITY;
  public static final Hit NO_HIT = new Hit(INFINITY);
  
	public float distance;
	public Surface surface;
	protected HitType type;
	
	protected Vector3f normal;
	
	public Hit(){}
  public Hit(float distance)
  {
        this.distance = distance;
  }
  
  public void setType(HitType type){
  	this.type = type;
  	type.setHit(this);
  }
  
  public TexCoord2f getTexCoord(){
  	return type.getTexCoord();
  }
  
  public Vector3f getNormal(){
  	if(this.normal == null)
  		this.normal = type.getNormal();
  	
  	return this.normal;
  }
  
  public Hit clone(){
  	return new Hit(distance);
  }
  

}
